import yaml,csv,json
import pandas
import os


def read_yaml(file_path):
    with open(file_path,'r',encoding='utf-8') as f:
        data = yaml.safe_load(f)
        print(data)
        return data

def readcsv(filePath):
    obj = pandas.read_csv(filePath,encoding='utf-8-sig')
    l = []
    for index, row in obj.iterrows():
        l.append((row['usercode'], row['username'], row['productcode'], row['productname'],
                  row['chaxunname'], row['exception']))
    print(l)
    return l
def readcsv2(filePath):
    obj = pandas.read_csv(filePath,encoding='gbk')
    l = []
    for index, row in obj.iterrows():
        l.append((row['merchantName'], row['yuqi'], row['exction']))
    print(l)
    return l
def read_json(file_path):
    with open(file_path,'r',encoding='utf-8') as f:
        data = json.load(f)
        print(data)
        return data

def read_excel(filePath):
    obj = pandas.read_excel(filePath)
    l = []
    for index, row in obj.iterrows():
        l.append((row['username_name'],row['bank_zh'],row["bh"]))
    print(l)
    return l



if __name__ == '__main__':

    current_dir = os.path.dirname(os.path.abspath(__file__))

    data_yaml_path = os.path.join(current_dir, '..', 'data', 'addproduct.yaml')
    data_json_path = os.path.join(current_dir, '..', 'data', 'peizhi.json')
    data_excel_path = os.path.join(current_dir, '..', 'data', 'aaa.xlsx')
    data_csv_path = os.path.join(current_dir, '..', 'data', 'type.csv')
    data_csv2_path = os.path.join(current_dir, '..', 'data', 'csv.csv')
    #
    read_yaml(data_yaml_path)
    readcsv(data_csv_path)
    readcsv2(data_csv2_path)
    read_json(data_json_path)
    read_excel(data_excel_path)

